#define SQLinside
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace Elte.SqlSpIdx
{
    public class Constants
    {

        public static string SPIDX = "_SPIDX_";

        public static string MyConnectionString = "username...valid connection string ";


        public static string db_name = "spatial";




        static Constants()
        {
            SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder();
            csb.DataSource = @".";
            csb.InitialCatalog = "spatial";
           
            csb.IntegratedSecurity = true;
            if (Microsoft.SqlServer.Server.SqlContext.IsAvailable)
            {
                MyConnectionString = "Context connection=yes";
            }
            else
            {
                MyConnectionString = csb.ConnectionString;
            }
            //SqlCommand s = new SqlCommand();
            //s.CommandText = Indices.IndexScripts.Spidx;
            //using (SqlConnection con = new SqlConnection(MyConnectionString))
            //{
            //    con.Open();
            //    s.Connection = con;
            //    s.ExecuteNonQuery();
            //}
        }


        public void HandleError(Exception ex)
        {
            WriteMessage("Error:" + Environment.NewLine + ex.Message);
        }

        public void WriteMessage(string message)
        {
            if (Microsoft.SqlServer.Server.SqlContext.IsAvailable)
            {
                Microsoft.SqlServer.Server.SqlContext.Pipe.Send(message);
            }
            else
            {
                Core.Log(message);

            }
        }



    }
}
